// 无重复字符的最长字串
#include<iostream>
#include<vector>
#include<unordered_set>
#include<unordered_map>


using namespace std;

class Solution{
public:
    int lengthOfLongestSubstring(string s){
        // @ 自己写的，存在问题 时间复杂度太高了
        unordered_set<char> temp;
        int max_length = 0;
        int left = 0;
        for(int i=0; i < s.size(); i++ ){
            for (int j=i; j < s.size(); j++){

                if(temp.find(s[j]) == temp.end()){
                    temp.insert(s[j]);
                }
                else{
                    // int temp_length = temp.size();
                    cout << "----" << endl;
                    temp.clear();
                    temp.insert(s[j]);
                }
                max_length = max(max_length, int(temp.size()));
            }
            temp.clear();
            
        }
        return max_length;

        // @优化的代码

    }
};


int main(){

    string s = "asjrgapa";
    Solution solution;
    int length = solution.lengthOfLongestSubstring(s);
    
    cout << "length is " << length << endl;

    return 0;
}

